import 'dart:math';

import 'package:flutter/material.dart';

final List<Color> colors = [
  Colors.red,
  Colors.pink,
  Colors.purple,
  Colors.deepPurple,
  Colors.indigo,
  Colors.blue,
  Colors.lightBlue,
  Colors.cyan,
  Colors.teal,
  Colors.green,
  Colors.orange,
  Colors.deepOrange,
  Colors.brown,
];

/// 获取随机颜色
Color getRandomColor(){
  var random = Random();
  int index = random.nextInt(colors.length);
  return colors[index];
}

/// 获取随机一定数量的颜色的集合
List<Color> getRandomColorList(int length){
  List<Color> colorList = [];
  var random = Random();
  int count = 0;
  while(count < length){
    int index = random.nextInt(colors.length);
    if(!colorList.contains(colors[index])){
      colorList.add(colors[index]);
      count++;
    }
  }
  return colorList;
}